home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 376-400 / disk_400 / reqlib / reqglue.asm < prev    next >
Assembly Source File  |  1992-05-06  |  5KB  |  272 lines

  1.  
  2.     include "libraries/reqbase.i"
  3.  
  4.     xref    _ReqBase
  5.  
  6.  
  7.  
  8. GLUE    MACRO
  9.     XDEF    _\1
  10. _\1
  11.     ENDM
  12.  
  13. NEWSYS    MACRO
  14.     PEA    _LVO\1            ;4
  15.     BRA    JumpIt            ;2 to 4.
  16.     ENDM
  17.  
  18. STACKOFFSET    EQU    4
  19.  
  20.  
  21.  
  22. GLUE2    MACRO
  23.     XDEF    _\1
  24. _\1
  25.     MOVEM.L    D2-D4/A2-A3/A6,-(SP)
  26.     ENDM
  27.  
  28. NEWSYS2    MACRO
  29.     MOVE.L    _ReqBase,A6
  30.     JSR    _LVO\1(A6)
  31.     MOVEM.L    (SP)+,D2-D4/A2-A3/A6
  32.     RTS
  33.     ENDM
  34.  
  35. STACKOFFSET2    EQU    28
  36.  
  37.  
  38.  
  39.     GLUE    Center
  40.     MOVE.L    STACKOFFSET(SP),A0
  41.     MOVEM.L    STACKOFFSET+4(SP),D0-D1
  42.     NEWSYS    Center
  43.  
  44.     GLUE    SetSize
  45.     MOVEM.L    STACKOFFSET(SP),D0-D1
  46.     NEWSYS    SetSize
  47.  
  48.     GLUE2    SetLocation
  49.     MOVEM.L    STACKOFFSET2(SP),D0-D2
  50.     NEWSYS2    SetLocation
  51.  
  52.     GLUE2    ReadLocation
  53.     MOVEM.L    STACKOFFSET2(SP),D0-D2
  54.     NEWSYS2    ReadLocation
  55.  
  56.     GLUE2    Format
  57.     MOVEM.L    STACKOFFSET2(SP),A0-A2
  58.     NEWSYS2    Format
  59.  
  60.     GLUE    FileRequester
  61.     MOVE.L    STACKOFFSET(SP),A0
  62.     NEWSYS    FileRequester
  63.  
  64.     GLUE    ColorRequester
  65.     MOVE.L    STACKOFFSET(SP),D0
  66.     NEWSYS    ColorRequester
  67.  
  68.     GLUE    ExtendedColorRequester
  69.     MOVE.L    STACKOFFSET(SP),A0
  70.     NEWSYS    ExtendedColorRequester
  71.  
  72.     GLUE2    DrawBox
  73.     MOVE.L    STACKOFFSET2(SP),A0
  74.     MOVEM.L    STACKOFFSET2+4(SP),D0-D3
  75.     NEWSYS2    DrawBox
  76.  
  77.     GLUE2    MakeButton
  78.     MOVEM.L    STACKOFFSET2(SP),A0-A2
  79.     MOVEM.L    STACKOFFSET2+12(SP),D0-D2
  80.     NEWSYS2    MakeButton
  81.  
  82.     GLUE2    MakeScrollBar
  83.     MOVE.L    STACKOFFSET2(SP),A0
  84.     MOVEM.L    STACKOFFSET2+4(SP),D0-D3
  85.     NEWSYS2    MakeScrollBar
  86.  
  87.     GLUE    PurgeFiles
  88.     MOVE.L    STACKOFFSET(SP),A0
  89.     NEWSYS    PurgeFiles
  90.  
  91.     GLUE    GetFontHeightAndWidth
  92.     NEWSYS    GetFontHeightAndWidth
  93.  
  94.     GLUE    MakeGadget
  95.     MOVEM.L    STACKOFFSET(SP),D0/A0-A1
  96.     EXG.L    D0,A0        ;Parameter are on the stack in the order A0,D0,A1.
  97.     NEWSYS    MakeGadget
  98.  
  99.     GLUE    MakeString
  100.     MOVE.L    STACKOFFSET(SP),A0
  101.     MOVEM.L    STACKOFFSET+4(SP),D0-D1
  102.     NEWSYS    MakeString
  103.  
  104.     GLUE    MakeProp
  105.     MOVE.L    STACKOFFSET(SP),A0
  106.     MOVEM.L    STACKOFFSET+4(SP),D0-D1
  107.     NEWSYS    MakeProp
  108.  
  109.     GLUE2    LinkGadget
  110.     MOVEM.L    STACKOFFSET2(SP),A0-A1/A3
  111.     MOVEM.L    STACKOFFSET2+12(SP),D0-D1
  112.     NEWSYS2    LinkGadget
  113.  
  114.     GLUE2    LinkStringGadget
  115.     MOVEM.L    STACKOFFSET2(SP),A0-A3
  116.     MOVEM.L    STACKOFFSET2+16(SP),D0-D3
  117.     NEWSYS2    LinkStringGadget
  118.  
  119.     GLUE2    LinkPropGadget
  120.     MOVEM.L    STACKOFFSET2(SP),A0/A3
  121.     MOVEM.L    STACKOFFSET2+8(SP),D0-D4
  122.     NEWSYS2    LinkPropGadget
  123.  
  124.     GLUE2    GetString
  125.     MOVEM.L    STACKOFFSET2(SP),A0-A2
  126.     MOVEM.L    STACKOFFSET2+12(SP),D0-D1
  127.     NEWSYS2    GetString
  128.  
  129.     GLUE    RealTimeScroll
  130.     MOVE.L    STACKOFFSET(SP),A0
  131.     NEWSYS    RealTimeScroll
  132.  
  133.     GLUE    TextRequest
  134.     MOVE.L    STACKOFFSET(SP),A0
  135.     NEWSYS    TextRequest
  136.  
  137.     GLUE    GetLong
  138.     MOVE.L    STACKOFFSET(SP),A0
  139.     NEWSYS    GetLong
  140.  
  141.     GLUE    RawKeyToAscii
  142.     MOVEM.L    STACKOFFSET(SP),D0-D1
  143.     MOVE.L    STACKOFFSET+8(SP),A0
  144.     NEWSYS    RawKeyToAscii
  145.  
  146.  
  147. ;         These  routines  are a little bit more work to write glue code for
  148. ; because  they  use  register  beyond  the  scratch  register  D0-D1/A0-A1.
  149. ; Therefore  these  registers  have  to be saved before values can be loaded
  150. ; into them.
  151.  
  152.  
  153.  
  154. ;         This  code was designed to minimize the overhead of the individual
  155. ; pieces of glue code for the individual routines.  With this 'helper' code,
  156. ; all  the  glue  code for each routine has to do is load the registers from
  157. ; the  stack  (no  way  to  avoid that), push the _LVO offset onto the stack
  158. ; (hard  to  avoid  doing  something like that) and then branch down to this
  159. ; routine.
  160.  
  161.     XDEF    JumpIt,StackCleanup    ;Make these visible to a debugger.
  162.  
  163. JumpIt
  164.     PEA    StackCleanup        ;Push the address of the code that restores A6.
  165.     MOVE.L    4(sp),-(sp)        ;Push the _LVO offset further down the stack
  166.     MOVE.L    A6,8(sp)        ;so that the old value of A6 can be stored
  167.                     ;above it.
  168.     MOVE.L    _ReqBase,A6
  169.     MOVE.L    D0,-(sp)
  170.     MOVE.L    A6,D0
  171.     ADD.L    D0,4(sp)        ;Add _ReqBase to the _LVO offset so when you go
  172.                     ;return, you'll branch to the routine.
  173.     MOVE.L    (sp)+,D0
  174.     RTS
  175. StackCleanup
  176.     MOVE.L    (sp)+,A6
  177.     RTS
  178.  
  179.  
  180.  
  181. ;;;;;         The  version  of this code for Aztec is really simple, since Aztec
  182. ;;;;; doesn't currently expect you to preserve A6.
  183. ;;;;
  184. ;;;;JumpIt
  185. ;;;;    MOVE.L    _ReqBase,A6
  186. ;;;;    MOVE.L    D0,-(sp)
  187. ;;;;    MOVE.L    A6,D0
  188. ;;;;    ADD.L    D0,4(sp)        ;Add _ReqBase to the _LVO offset so when you go
  189. ;;;;                    ;return, you'll branch to the routine.
  190. ;;;;    MOVE.L    (sp)+,D0
  191. ;;;;    RTS
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199. SureText    DC.B    "  Ok  ",0
  200. CancelText    DC.B    "Cancel",0
  201. ResumeText    DC.B    "Resume",0
  202.  
  203.     even
  204.  
  205.  
  206.     GLUE    SimpleRequest
  207.     MOVE.L    STACKOFFSET(SP),A0
  208.     LEA    STACKOFFSET+4(SP),A1
  209.     BRA    SimpleRequest
  210.  
  211.     GLUE    TwoGadRequest
  212.     MOVE.L    STACKOFFSET(SP),A0
  213.     LEA    STACKOFFSET+4(SP),A1
  214.     BRA    TwoGadRequest
  215.  
  216.  
  217.  
  218. srRegs    REG    A2-A4/D2
  219.  
  220. ;----------------------------------------------------
  221.     public    TwoGadRequest
  222. TwoGadRequest:
  223. ;Bool=TwoGadRequest(String,Controls)
  224. ;                     A0      A1
  225.  
  226.     MOVEM.L    srRegs,-(sp)
  227.     LEA.L    SureText,A2
  228.     LEA.L    CancelText,A3
  229.     BRA.S    TheRequest
  230.  
  231.     public    SimpleRequest
  232. SimpleRequest:
  233.  
  234. ;SimpleRequest(Text,Controls)
  235. ;               A0    A1
  236. ; This is just a method of telling a user something. It just calls MultiRequest
  237. ; with no gadgets.
  238.  
  239.     MOVEM.L    srRegs,-(sp)
  240.     SUBA.L    A2,A2
  241.     LEA.L    ResumeText,A3
  242.  
  243. TheRequest
  244.  
  245.     MOVE.L    _ReqBase,A6    ;Load A6 from the data segment _before_ tromping on A4.
  246.  
  247.     SUB.W    #TR_SIZEOF,SP        ;get some temporary storage.
  248.  
  249.     MOVE.L    SP,A4
  250.     MOVEQ    #TR_SIZEOF/2-1,D2    ;because the stack is almost never clear.
  251. 1$    CLR.W    (A4)+
  252.     DBF    D2,1$
  253.  
  254.     MOVE.L    A0,TR_Text(SP)
  255.     MOVE.L    A1,TR_Controls(SP)
  256.     MOVE.L    A2,TR_PositiveText(SP)
  257.     MOVE.L    A3,TR_NegativeText(SP)
  258.  
  259.     MOVE.W    #$FFFF,TR_KeyMask(SP)
  260.  
  261.     MOVE.L    SP,A0
  262.     JSR    _LVOTextRequest(A6)
  263.  
  264.     ADD.W    #TR_SIZEOF,SP
  265.  
  266.     MOVEM.L    (sp)+,srRegs
  267.     RTS
  268.  
  269.  
  270.  
  271.     END
  272.